<template>
  <div class="main-wrapper " :class="{hideAll:hideAll}" @click.alt.prevent.stop="tohideAll" >
      <!--@click.meta.prevent.stop="pageSwitch"-->
      <router-view :loaded="loaded"></router-view>
    <i :class="fullClass" title="全屏/非全屏" @click.prevent.stop="tohideAll()"></i>

  </div>
</template>

<script>

  import tool from 'src/util/tool';
  import util from '_util/index';
  import loading from 'components/dimmer/loading';

  const RS_OK = 1
  export default {
    data() {
      return {
        path: '',
        loaded:false,
        hideAll: false,
      }
    },
    methods: {

      tohideAll() {

        let tmp = !this.hideAll
          $('.header-wrapper').css({
              'z-index': tmp?10:13
          });
        this.hideAll = tmp
      },
      pageSwitch() {
        delete this.$route.query['_id']
        util.jump(this, 1)
      },
      forRead(id,ctl,clb){
        let param = {
          id: id
        }
        let url = tool.getApi(this,ctl, 'read');
        util.getDataCom(this, url, param, (rs) => {
          util.store.commit(this,'setEditVo', rs);
          clb();
          this.loaded=true
        })
      },
      forRoute(route){
        this.loaded=false
        util.store.commit(this,'setIslist', false);

        let path=route.path
        let id=route.query._id
        let ctl=route.query.ctl

//        util.store.push(_this, 'setIsinEditModal', 'isinEditModal', false, false, 'edit');

        if(path=='/page/edit'&&id){
          this.forRead(id, ctl, () => {
            util.store.commit(this,'setOp', 'update');
          });

        }
        else if(path=='/page/detail'&&id){
          this.forRead(id, ctl, () => {
            util.store.commit(this,'setOp', 'detail');
          });
        }
        else if(path=='/page/copy'&&id){
          this.forRead(id, ctl, () => {
            util.store.commit(this,'setOp', 'copy');
          });
        }else {
          if(path=='/page/add'){
            util.store.commit(this,'setOp', 'insert');
          }else if(path=='/page/list'){
            util.store.commit(this,'setIslist', true);
            util.store.commit(this,'setOp', '');
          }else
            util.store.commit(this,'setOp', '');
          delete route.query['_id']
          util.store.commit(this,'setEditVo', {});
          this.loaded=true
        }
      }
    },
    watch: {
      "$route": function(val, old) {
        this.forRoute(val)
      }
    },
    computed: {
      fullClass() {
        return this.hideAll ? 'icon-outfull' : 'icon-fullscreen';
      },
    },
    components: {loading},
    props: [],
    created() {
      this.forRoute(this.$route)
    },
    mounted(){
//	this.$store.dispatch('module_permission/initLimitData');//初始化权限数组
    }
  }
</script>

<style rel="stylesheet/less" lang="less" scoped>@import "../../common/style/mixin";

@dir: "common/";

.main-wrapper {
  .main-place();
  &.hideAll {
    .icon-fullscreen,
    .icon-outfull {
      .main-position-right-hideAll();
    }
  }
  .icon-fullscreen,
  .icon-outfull {
    .main-position-right();
    font-size: 24px;
    padding: 0 0 8px 8px;
    display: block;
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    &:hover {
      color: rgba(0, 0, 0, 0.9);
    }
  }
}
</style>
